﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace csis.ImmediatorClasses
{
	/// <summary>
	/// Represents a compile unit and its attributes.
	/// </summary>
	public class Script
	{
		public Script(string filePath)
		{
			if (String.IsNullOrEmpty(filePath)) throw new ArgumentOutOfRangeException("filePath", "No file path specified");

			this.FilePath = filePath;
		}
		

		/// <summary>
		/// Contains the original file path.
		/// </summary>
		public string FilePath { get; private set; }
		public bool UseQuickHeader { get; set; }
		/// <summary>
		/// The line after which the automain template should be expanded.
		/// </summary>
		public int? AutoMain { get; set; }
		/// <summary>
		/// The path of the file that is actually being compiled.
		/// Can be FilePath if no further preprocessing is required, or a temporary file path
		/// if the file needs to be modified through the preprocessor.
		/// </summary>
		public string GetCompiledFilePath()
		{
			if (this.TemporaryScript != null)
			{
				return this.TemporaryScript.FileName;
			}
			else
			{
				return this.FilePath;
			}
		}

		/// <summary>
		/// Can be specified if this file is not compiled directly, but through a temporary
		/// script file. This happens if preprocessor directives transform the script prior
		/// to compilation.
		/// </summary>
		public TemporaryFile TemporaryScript { get; set; }
	}
}
